<?php
Class IndexAction extends Action {
    Public function index(){
        //测试
        $today = array(05,14,21,29,30,01,'09',
            10,15,26,31,32,03,12,
            04,'08',16,22,32,01,05,
            04,05,11,13,15,05,11,
            '08',12,22,30,35,02,06,
            02,11,15,19,22,04,'09');
        $aa = array_count_values ($today);
        $bb = ksort($aa,SORT_NUMERIC);
        $bb = arsort($aa,SORT_NUMERIC);
//        $exiexs = array(01,'09',12,16,27,03);
//        foreach($aa as $k => $v){
//            if(in_array($k,$exiexs)){
//                unset($aa[$k]);
//            }
//        }
        p($aa);die;
        $del_aa = $aa;
//        $current = array(25,29,34);
        foreach ($del_aa as $k => $v){
            if(in_array($k,$current)){
                unset($del_aa[$k]);
            }
        }
        p($del_aa);die;

        if(!$lists = S('index_list')){
            $lists = M('cate') -> where(array('pid' => 0)) -> order('sort') -> select();
            import('Class.Category',APP_PATH);
            $cate = M('cate') -> order('sort') -> select();
            $blog = M('blog');
            $field = array('id','title','time');
            foreach($lists as $k => $v){
                $cids = Category::getChildsId($cate,$v['id']);
                $cids[] = $v['id'];
                $where = array('cid' => array('in',$cids));
                $lists[$k]['blog'] = $blog -> field($field) -> where($where) -> order("time DESC") -> select();
            }
            //加入缓存，第一个参数缓存名称，第二个参数存储的变量，第三个参数缓存时间，
            //如果首页不常更新的话一般存一天也可以3600*24单位是s，
            //加缓存是为了不用经常去访问数据库，为数据库减轻压力
            //通常如果发现更改以后页面一直没有变化，考虑是不是因为缓存的原因，缓存时间太长了，可以把缓存时间改小一些
            //同时可以把runtime里面的缓存删掉，让缓存重新生成一遍
            S('index_list',$lists,10);
        }

//        $this->cate = $topCate;
        $this -> assign('cates',$lists);
        $this -> display();
    }

    //测试
    Public function ceshi(){
        //测试
        $today = array(04,'08',11,14,34,11,12,
            03,18,29,32,35,03,07,
            14,16,19,29,34,01,12,
            07,18,25,29,34,10,11,
            06,12,19,20,25,04,06,
            20,21,23,25,29,07,12);
        $aa = array_count_values ($today);
        $bb = ksort($aa,SORT_NUMERIC);
        $bb = arsort($aa,SORT_NUMERIC);

        $exiexs = array(05,28,31,35,'08','09');
        foreach($aa as $k => $v){
            if(in_array($k,$exiexs)){
                unset($aa[$k]);
            }
        }

        $del_aa = $aa;
        $current = array(25,29,34);
        foreach ($del_aa as $k => $v){
            if(in_array($k,$current)){
                unset($del_aa[$k]);
            }
        }
        p($del_aa);die;
        $current = array(
            02,12,25,29,34,07,11,
            02,11,25,29,34,07,12,
            07,13,25,29,34,11,12,
            02,07,25,29,34,11,12,
            07,15,25,29,34,11,12,
        );
        $current1 = array(
            07,17,25,29,34,11,12,
            07,22,25,29,34,11,12,
            04,12,25,29,34,06,11,
            06,12,25,29,34,04,11,
            03,12,25,29,34,01,11,
        );
        $current2 = array(
            06,12,25,29,34,03,11,
            04,12,25,29,34,03,11,
            01,12,25,29,34,03,11,
            07,12,25,29,34,03,11,
            01,07,25,29,34,03,11,
        );
        $current4 = array(
            03,12,25,29,34,05,12,
            03,11,25,29,34,06,12,
            03,12,25,29,34,05,11,
            03,11,25,29,34,06,11,
            07,11,25,29,34,11,12,
        );
        $current5 = array(
            01,07,25,29,34,03,'08',
            11,12,25,29,34,03,06,
            01,12,25,29,34,03,04,
            01,11,25,29,34,04,06,
            11,12,25,29,34,06,'08',
            03,11,25,29,34,07,11,
        );

        //Array ( [12] => 4 [29] => 4 [25] => 3 [34] => 3 [11] => 3 [7] => 3 [19] => 2 [20] => 2 [3] => 2 [18] => 2 [14] => 2 [6] => 2 [4] => 2 [35] => 1 [32] => 1 [16] => 1 [08] => 1 [10] => 1 [1] => 1 [21] => 1 [23] => 1 )
        /*   $yes = array(03,08,16,17,35,07,12,
                        05,15,21,29,35,08,10,
                        14,15,26,29,31,05,11,
                        09,13,19,20,28,02,12,
                        01,14,19,21,28,05,10,
                        01,20,26,31,35,02,05,);
           $aa = array_count_values ($yes);
           $bb = ksort($aa,SORT_NUMERIC);
           print_r($aa);*/
        //测试
        $today = array(02,23,29,32,35,01,'08',
            03,13,26,27,33,'09',11,
            10,12,13,19,28,04,05,
            05,07,22,26,32,05,'08',
            '09',12,14,15,35,'09',10,
            05,'09',18,22,28,06,11
        );
        $aa = array_count_values ($today);
        $bb = ksort($aa,SORT_NUMERIC);
        $bb = arsort($aa,SORT_NUMERIC);
        p($aa);
        die;
    }
}